package cn.tedu.web.mapper;

import cn.tedu.web.entity.Address;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author issen
 * @since 2021-10-18
 */
@Mapper
public interface AddressMapper extends BaseMapper<Address> {
    // 判断指定用户的地址是否存在
    @Select("SELECT COUNT(1) FROM ec_address WHERE uid = #{uid} AND province = #{province} AND city = #{city} AND area = #{area} AND stress = #{stress}")
    public boolean exits(Address address);

    // 保存地址信息
    @Insert("INSERT INTO ec_address (`uid`, `province`, `city`, `area`, `stress`) VALUES (#{uid}, #{province}, #{city}, #{area}, #{stress});")
    public Integer save(Address address);
}
